GdkQuartz: Handle NULL from [NSGraphicsContext currentContext].
authorJohn Ralls <jralls@ceridwen.us>
Sat, 20 Oct 2018 19:27:46 +0000 (12:27 -0700)
committerJohn Ralls <jralls@ceridwen.us>
Thu, 1 Nov 2018 22:39:27 +0000 (15:39 -0700)
By returning a default surface. The situation where there's no
currentContext arises when GtkCSS is trying to determine the
layout sizes so no actual display is necessary.

Closes: #1411
gdk/quartz/gdksurface-quartz.c

index ff7c62a688c11f75ea1652beb0b9513512f55cba..ca4a54aaabb47162ae03738e7c4565628b33d6c4 100644 (file)
@@ -135,9 +135,11 @@ gdk_surface_impl_quartz_get_context (GdkSurfaceImplQuartz *surface_impl,
         return NULL;
     }
   if (gdk_quartz_osx_version () < GDK_OSX_YOSEMITE)
-       cg_context = [[NSGraphicsContext currentContext] graphicsPort];
+    cg_context = [[NSGraphicsContext currentContext] graphicsPort];
   else
-       cg_context = [[NSGraphicsContext currentContext] CGContext];
+    cg_context = [[NSGraphicsContext currentContext] CGContext];
+  if (!cg_context)
+    return NULL;
   CGContextSaveGState (cg_context);
   CGContextSetAllowsAntialiasing (cg_context, antialias);
 
@@ -278,15 +280,15 @@ gdk_quartz_create_cairo_surface (GdkSurfaceImplQuartz *impl,
 
   cg_context = gdk_quartz_surface_get_context (impl, TRUE);
 
-  if (!cg_context)
-    return NULL;
-
   surface_data = g_new (GdkQuartzCairoSurfaceData, 1);
   surface_data->surface_impl = impl;
   surface_data->cg_context = cg_context;
 
-  surface = cairo_quartz_surface_create_for_cg_context (cg_context,
-                                                        width, height);
+  if (cg_context)
+    surface = cairo_quartz_surface_create_for_cg_context (cg_context,
+                                                          width, height);
+  else
+    surface = cairo_quartz_surface_create(CAIRO_FORMAT_ARGB32, width, height);
 
   cairo_surface_set_user_data (surface, &gdk_quartz_cairo_key,
                                surface_data,